import {
	request,
	baseUrlShop
} from "../../request.js"

/**
 * 1，获取超市商品分类
 */
export function getShopType() {
	return request({
		url: baseUrlShop + '/shopType/findAll',
		method: 'GET'
	})
}

/**
 * 2，商品数据
 * @param {Object} page 
 * @param {Object} size
 * @param {Object} commodityName
 */
export function getCommodityByPage(tid, page, size, commodityName) {
	return request({
		url: baseUrlShop + '/shopCommodity/findConditionByPage',
		method: 'POST',
		data: {
			body: {
				shopType: tid,
				commodityName: commodityName
			},
			page: page,
			size: size
		}
	})
}

/**
 * 3，发布商品
 * @param {Object} addData
 */
export function addCommodityData(addData) {
	return request({
		url: baseUrlShop + '/shopCommodity/insert',
		method: 'POST',
		data: {
			commodityName: addData.commodityName,
			price: addData.price,
			detail: addData.detail,
			num: addData.num,
			logoUrl: addData.logoUrl,
			releaseId: addData.releaseId,
			address: addData.address,
			shopType: addData.shopType
		}
	})
}

export function queryType(typeId) {
	return request({
		url: baseUrlShop + '/type/findById/' + typeId,
		method: 'GET'
	})
}
